package org.embedchat.database.nodb;

import java.util.ArrayList;
import java.util.List;

import org.embedchat.database.ChatRoomDAOInterface;
import org.embedchat.database.ItemNotFoundException;
import org.embedchat.entity.ChatRoom;

public class ChatRoomDAO implements ChatRoomDAOInterface {

	public static ChatRoom room1;
	public static ChatRoom room2;
	
	static {
		room1 = new ChatRoom();
		room1.setId(1l);
		room1.setDescription("This is default room, if you don't use some database implementations");
		room1.setMaxConcurrentGuests(100);
		room1.setMaxConcurrentRegisteredUsers(0);
		room1.setName("Default room");
		room1.setWebURL("http://www.embedchat.org");
		
		room2 = new ChatRoom();
		room2.setId(2l);
		room2.setDescription("This is test room");
		room2.setMaxConcurrentGuests(100);
		room2.setMaxConcurrentRegisteredUsers(0);
		room2.setName("Test room");
		room2.setWebURL("http://www.embedchat.org");
		
	}
	
	public ChatRoom findChatRoom(Long chatRoomId) throws ItemNotFoundException {
		if (chatRoomId.equals(1L)) {
			return room1;
		} else {
			return room2;
		}
	}

	public List<ChatRoom> findAll() {
		ArrayList<ChatRoom> list = new ArrayList<ChatRoom>();
		list.add(room1);
		list.add(room2);		
		return list;
	}

}
